import GameData_red_blue_man from "./GameData_red_blue_man";

const {ccclass, property} = cc._decorator;

@ccclass
export default class GiftMistake extends cc.Component {

    @property(cc.Node)
    finger: cc.Node = null;
    @property(cc.Node)
    frame: cc.Node[] = [];

    onLoad () {
        this.finger.active = false;
    }

    start () {

    }

    showHand(){
        this.finger.active = true;
        let num = 0;
        if(GameData_red_blue_man.giftNodeList.length == 1){
            num = 0;
        }else if(GameData_red_blue_man.giftNodeList.length < 1){
            this.finger.active = false;
            return;
        }else{
            num = Math.round(Math.random() * (GameData_red_blue_man.giftNodeList.length - 1));
        }

        console.log(GameData_red_blue_man.giftNodeList[num])
        this.finger.x = this.frame[GameData_red_blue_man.giftNodeList[num]].x + 100;
    }

    callback = null;
    setCallback(call){
        this.callback = call;
    }

    onClick(){
        if(this.callback){
            this.callback();
            this.node.destroy();
        }else{
            this.node.destroy();
        }
    }

    // update (dt) {}
}
